package Test.stream流测试;

import java.util.*;
import java.util.function.IntFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @Author kirito
 * @Date 2023/12/13 19:01
 * @PackageName:Test.stream流测试
 * @ClassName: a
 * @Description:
 * @Version 1.0
 */
public class StreamDemo6 {
    public static void main(String[] args) {
        /**
         * 匹配的练习
         */
        List<Integer> integers = Arrays.asList(124, 2, 15, 12, 51, -5, 5);
        // 判断是否全部大于5
        boolean b = integers.stream().allMatch(i -> i > 5);
        // 结束输出false
        System.out.println(b);

        System.out.println("-------");

        List<Integer> integers2 = Arrays.asList(124, 2, 15, 12, 51, -5, 5);
        // 检测是否匹配至少一个元素
        boolean b1 = integers2.stream().anyMatch(i -> i > 5);
        // 输出true
        System.out.println(b1);

        System.out.println("-------");

        List<Integer> integers3 = Arrays.asList(124, 2, 15, 12, 51, -5, 5);
        // 检查是否没有匹配的元素
        boolean b2 = integers3.stream().noneMatch(i -> i > 1000);
        // 输出true，全部不匹配
        System.out.println(b2);
    }
}


